<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<link rel="stylesheet" href="<?=LAY_PATH?>css/layui.css">

<div class="pad-lr-10" style="width: 850px;margin:auto">
    <form class="layui-form" id="form" method="post" enctype="multipart/form-data" action="index.php?m=webman&c=contact&a=edit">
        <table class="layui-table">
			<tr>
				<p style="text-align:center;font-size:20px;line-height:40px;margin-top:20px;">联系方式</p>
			</tr>
			<tr>
				<td><p style="">公司名称：</p><input type="text" name="title" value="<?php echo $data[0]['title']?>" /></td>
			</tr>
			<tr>
				<td><p style="">联系人：</p><input type="text" name="contact" value="<?php echo $data[0]['contact']?>" /></td>
			</tr>
			<tr>
				<td><p style="">电话号码：</p><input type="text" name="tel" value="<?php echo $data[0]['tel']?>" /></td>
			</tr>
			<tr>
				<td><p style="">手机号码：</p><input type="text" name="phone" value="<?php echo $data[0]['phone']?>" /></td>
			</tr>
			<tr>
				<td><p style="">电子邮箱：</p><input type="text" name="email" value="<?php echo $data[0]['email']?>" /></td>
			</tr>
			<tr>
				<td><p style="">QQ：</p><input type="text" name="qq" value="<?php echo $data[0]['qq']?>" /></td>
			</tr>
			<tr>
				<td><p style="">微信：</p><input type="text" name="weixin" value="<?php echo $data[0]['weixin']?>" /></td>
			</tr>
			<tr>
				<td><p style="">公司地址：</p><input type="text" name="address" value="<?php echo $data[0]['address']?>" /></td>
			</tr>
			<tr>
				<td><p style="">二维码：</p><img class="bimg" style="width:100px;" src="<?php echo $data[0]['erweima']?>" /><input type="file" name="erweima" id="filess" value="修改" style="width:25% !important;" /></td>
			</tr>
			<input type="hidden" name="erweima" id="erweima" value="<?php echo $data[0]['erweima']?>" />
			<input type="hidden" name="erweima2" id="erweima" value="<?php echo $data[0]['erweima']?>" />
			<input type="hidden" name="id" value="<?php echo $data[0]['id']?>" />
        </table>
		<div style="width: 120px;margin:auto">
        <button style="background: #2f4050;color:#fff" class="layui-btn add">修改</button> 
    </div>
    </form>
    



</div>
<style>
	input{
		border:none !important;
		background:none !important;
		line-height:40px;
		height:35px !important;
		font-size:14px !important;
		width:80% !important;
	}
	table tr td p{
		display:inline-block;
		line-height:40px;
		height:41px !important;
		font-size:14px !important;
	}
</style>
<script src="<?=LAY_PATH?>layui.js"></script>
<script>

    layui.use(['layer','form'],function(){
        $(".add").click(function(){
            $(".add").css("display","none")
            if($("td").hasClass("edit_c")){
                layer.msg("请先完成图片上传操作或者取消",{icon:2})
            }else {
                $.ajax({
                    url: "index.php?m=webman&c=index&a=tel_add&pc_hash=<?=$_SESSION['pc_hash']?>",
                    type: "post",
                    success: function (msg) {
                        $('tbody').append(msg)
                    }
                })

            }
        })
    })

</script>

<script type="text/javascript">

	$("#filess").change(function(){
		var data = new FormData();
		$.each($('#filess')[0].files, function(i, file) {
            data.append('upload_file'+i, file);
        });
		$.ajax({
			url:"index.php?m=webman&c=contact&a=filess&pc_hash=<?=$_SESSION['pc_hash']?>",
			type:"post",
			data:data, 
			cache: false,
            contentType: false,        /*不可缺*/
            processData: false,
			success:function(res){
				if(res==0){
					alert("上传失败")
				}else if(res==2){
					alert('未上传文件')
				}else{
					$(".bimg").attr("src",res)
					$("#erweima").val(res)
				}
			}
		})
	})
	$("#butt").click(function(){
		$.ajax({
            url:"index.php?m=webman&c=contact&a=edit&pc_hash=<?=$_SESSION['pc_hash']?>",
            type:"post",
            data:$("#form").serialize(),
            success:function(msg){
                if(msg=='ok'){
                    layer.msg('修改成功',{icon:1},function(){
                        location.reload();
                    })
                }else if(msg=='fail'){
                    layer.msg('修改失败，请联系管理员',{icon:2})
                }else{
                    layer.msg(msg,{icon:2})
                }
            }
        })
	})




    /*phpcms函数，窗口撑开*/
    function test_spider(id) {
        window.top.art.dialog({id:'test'}).close();
        window.top.art.dialog({title:'<?php echo L('data_acquisition_testdat')?>',id:'test',iframe:'?m=collection&c=node&a=public_test&nodeid='+id,width:'700',height:'500'}, '', function(){window.top.art.dialog({id:'test'}).close()});
    }

    function copy_spider(id) {
        window.top.art.dialog({id:'test'}).close();
        window.top.art.dialog({title:'<?php echo L('copy_node')?>',id:'test',iframe:'?m=collection&c=node&a=copy&nodeid='+id,width:'420',height:'120'}, function(){var d = window.top.art.dialog({id:'test'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'test'}).close()});
    }

    function import_spider() {
        window.top.art.dialog({id:'test'}).close();
        window.top.art.dialog({title:'<?php echo L('import_collection_points')?>',id:'test',iframe:'?m=collection&c=node&a=node_import',width:'420',height:'200'}, function(){var d = window.top.art.dialog({id:'test'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'test'}).close()});
    }
    /*phpcms函数，窗口撑开*/

    /*临时图片显示函数*/
    function preview(file)
    {
        var prevDiv = document.getElementById('preview');
        if (file.files && file.files[0])
        {
            var reader = new FileReader();
            reader.onload = function(evt){
                prevDiv.innerHTML = '<img src="' + evt.target.result + '" height="80" width="300"  />';
            };
            reader.readAsDataURL(file.files[0]);
        }
        else
        {
            prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
        }
    }

    window.top.$('#display_center_id').css('display','none');
    //-->
    /*ajax删除*/
    function del(id){
        layer.confirm('确定删除吗？', {
            btn: ['确定', '取消'] //可以无限个按钮
        }, function(index, layero){
            $.post("index.php?m=webman&c=index&a=tel_delete&pc_hash=<?=$_SESSION['pc_hash']?>", {id: id}, function (msg) {
                if (msg == "ok") {
                    layer.msg('删除成功', {icon: 1}, function () {
                        location.reload();
                    })
                }
            })
        }, function(index){
            
        });
    }


    function edit(id){
        $(".add").css("display","none")
        $.post("index.php?m=webman&c=contact&a=edit&pc_hash=<?=$_SESSION['pc_hash']?>",{id:id},function (msg) {
            $("#"+id).html(msg)
        });
    }

    function add1(){
        $.ajax({
            url:"index.php?m=webman&c=index&a=tel_add&pc_hash=<?=$_SESSION['pc_hash']?>",
            type:"post",
            data:$("#form").serialize(),
            success:function(msg){
               if(msg=='ok'){
                   layer.msg('添加成功',{icon:1}, function () {
                       location.reload();
                   })
               }else if(msg=='fail'){
                   layer.msg('添加失败，请联系管理员',{icon:2})
               }else{
                   layer.msg(msg,{icon:2})
               }
            }
        })
    }
    function edit1(){
        $.ajax({
            url:"index.php?m=webman&c=index&a=tel_edit&pc_hash=<?=$_SESSION['pc_hash']?>",
            type:"post",
            data:$("#form").serialize(),
            success:function(msg){
                if(msg=='ok'){
                    layer.msg('修改成功',{icon:1},function(){
                        location.reload();
                    })
                }else if(msg=='fail'){
                    layer.msg('添加失败，请联系管理员',{icon:2})
                }else{
                    layer.msg(msg,{icon:2})
                }
            }
        })
    }
</script>
<script>



    layui.use(['layer','form','upload','jquery'], function(){
        var form = layui.form;  var layer = layui.layer;
        var $ = layui.jquery
            ,upload = layui.upload;




    });

</script>
</body>
</html>